/*
 * @Author: szx
 * @Date: 2022-04-01 15:20:50
 * @LastEditTime: 2022-04-01 15:34:45
 * @Description:
 * @FilePath: \leetcode\剑指offerII\019\019.js
 */
/**
 * @param {string} s
 * @return {boolean}
 */
 var validPalindrome = function (s) {
    i = 0,
        j = s.length - 1;
    while (i < j) {
        if (s[i] !== s[j]) {
            return isValid(s, i + 1, j) || isValid(s, i, j - 1);
        }
        i++;
        j--;
    }
    return true;
};
function isValid(s, i, j) {
    while (i < j) if (s[i++] != s[j--]) return false;
    return true;
}
